package ink.lovejinhu.leetcodeMatch;

import java.util.HashMap;

public class Solution_5804 {
    public boolean areOccurrencesEqual(String s) {
        char[] chars = s.toCharArray();
        int max = 0;
        HashMap<Character, Integer> res = new HashMap<>();
        for (int i = 0; i < chars.length; i++) {
            if (res.containsKey(chars[i])) {
                Integer temp = res.get(chars[i]);
                temp++;
                res.put(chars[i], temp);
            } else {
                res.put(chars[i], 1);
            }
        }
        int temp = Integer.MAX_VALUE;
        for (char v0 : res.keySet()
        ) {
            if (temp == Integer.MAX_VALUE) {
                temp = res.get(v0);
            } else {
                if (temp != res.get(v0)) {
                    return false;
                }
            }

        }
        return true;
    }
}
